package Presentacion.academico;

import clases.incio.ButtonEditor;
import clases.incio.ButtonRenderer;
import global.Dialogos;
import global.Iconos;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Moreria
 */
public final class dlgAcademico extends javax.swing.JDialog {
    public static DefaultTableModel modelo;
    private Iconos ico = new Iconos();

    /**
     * Creates new form dlgAcademico
     *
     * @param parent
     * @param modal
     */
    public dlgAcademico(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setResizable(false);
        setTitle("REGISTRO DE DATOS ACADEMICOS DEL ALUMNO");
        setLocationRelativeTo(this);
        iconos();
        frmConsultaAcademico.objAcademico.listarDatoAcademico(cbodato);
        visiblidad(true);
        limpiarTodo();
    }

    private void iconos() {
        btnnuevo.setIcon(ico.getNuevo());
        btnguardar.setIcon(ico.getGuardar());
        btnsalir.setIcon(ico.getSalir());
        btnactualizar.setIcon(ico.getActualizar());
    }

    public void armarmodeloAcademico() {
        modelo = new DefaultTableModel() {
            @Override
            public boolean isCellEditable(int fila, int columna) {
                return columna == 2;
            }
        };
        tblAcademico.setModel(modelo);
        modelo.addColumn("DATO ACADEMICO");
        modelo.addColumn("DESCRIPCION");
        modelo.addColumn("QUITAR");

        TableColumn columna = new TableColumn();

        columna = tblAcademico.getColumnModel().getColumn(0);
        columna.setPreferredWidth(300);
        columna = tblAcademico.getColumnModel().getColumn(1);
        columna.setPreferredWidth(300);
    }

    private boolean Valadicaion() {
        if (txtcedula.getText().equals("")) {
            global.Mensajes.mostrarMensaje("Advertencia!", "Seleccione el alumno", 2);
            return false;
        } else if ("--Seleccione--".equals(cbodato.getSelectedItem())) {
            Dialogos.FaltaCampo("Dato Academico");
            cbodato.requestFocus();
            return false;
        } else if ("".equals(txtDescripcion.getText())) {
            Dialogos.FaltaCampo("Descripcion");
            txtDescripcion.requestFocus();
            return false;
        }
        return true;
    }

    private void agregar() {
        String fila[];
        fila = new String[3];
        fila[0] = cbodato.getSelectedItem().toString();
        fila[1] = txtDescripcion.getText();
        tblAcademico.getColumnModel().getColumn(2).setCellRenderer(new ButtonRenderer());
        tblAcademico.getColumnModel().getColumn(2).setCellEditor(
                new ButtonEditor(new JCheckBox(), modelo, tblAcademico));
        modelo.addRow(fila);
        limpiarAcademico();
    }

    private void agregarAcademico() {

        if (Valadicaion() == true) {
            if (btnactualizar.isVisible() == false) {
                if (verificarDatoCombo(modelo, tblAcademico, cbodato) == false
                        && frmConsultaAcademico.objAcademico.ExistenciaAcademico(cbodato.getSelectedItem().toString(), txtcedula.getText()) == false) {
                    agregar();
                } else {
                    Dialogos.Error("El dato académico ya esta agregado al alumno");
                }
            } else {
                if (verificarDatoCombo(modelo, tblAcademico, cbodato) == false) {
                    agregar();
                } else {
                    Dialogos.Error("El dato académico ya esta agregado al alumno");
                }
            }

        }
    }

    private void llenarTablaAcademico(int fila) {
        if (tblAcademico.getRowCount() != 0) {
            cbodato.setSelectedItem(modelo.getValueAt(fila, 0).toString());
            txtDescripcion.setText(modelo.getValueAt(fila, 1).toString());
            modelo.removeRow(tblAcademico.getSelectedRow());
        }
    }

    public void visiblidad(boolean visibilidad) {
        if (visibilidad != true) {
            btnactualizar.setVisible(true);
            btnguardar.setVisible(false);
        } else {
            btnactualizar.setVisible(false);
            btnguardar.setVisible(true);
        }
    }

    private boolean verificarDatoCombo(DefaultTableModel modelo, JTable tabla, JComboBox combo) {
        for (int i = 0; i < modelo.getRowCount(); i++) {
            if (tabla.getValueAt(i, 0).equals(combo.getSelectedItem().toString())) {
                return true;
            }

        }
        return false;
    }

    private void limpiarAcademico() {
        cbodato.setSelectedIndex(0);
        txtDescripcion.setText("");
        cbodato.requestFocus();
    }

    private void limpiarTodo() {
        btnbuscar.setVisible(true);
        txtalumno.setText("");
        txtcedula.setText("");
        armarmodeloAcademico();
        limpiarAcademico();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PanelAcademico = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblAcademico = new javax.swing.JTable();
        btnagregarAcademicos = new javax.swing.JButton();
        cbodato = new javax.swing.JComboBox();
        btnTipoAcademico = new javax.swing.JButton();
        txtDescripcion = new javax.swing.JTextField();
        jToolBar4 = new javax.swing.JToolBar();
        btnnuevo = new javax.swing.JButton();
        btnguardar = new javax.swing.JButton();
        btnactualizar = new javax.swing.JButton();
        btnsalir = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        txtcedula = new javax.swing.JTextField();
        btnbuscar = new javax.swing.JButton();
        txtalumno = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        PanelAcademico.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel18.setText("DATO ACADÉMICO");

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel21.setText("DESCRIPCIÓN");

        tblAcademico.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblAcademico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblAcademicoMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblAcademico);

        btnagregarAcademicos.setText("Agregar");
        btnagregarAcademicos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnagregarAcademicosActionPerformed(evt);
            }
        });

        cbodato.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccione--", "INSTITUCION EDUCATIVA DE PROCEDENCIA", "AÑO BASICO/BACHILLERATO QUE INGRESA", "PROMEDIO ACADEMICO", "PROMEDIO DISCIPLINARIO", "AREAS O ASIGNTURAS QUE SE DSTAQUE", "AREAS O ASIGNTURAS QUE NO SE DSTAQUE", "EXPECTATIVAS EN LA INSTITUCION" }));

        btnTipoAcademico.setText("+");
        btnTipoAcademico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTipoAcademicoActionPerformed(evt);
            }
        });

        txtDescripcion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtDescripcionKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout PanelAcademicoLayout = new javax.swing.GroupLayout(PanelAcademico);
        PanelAcademico.setLayout(PanelAcademicoLayout);
        PanelAcademicoLayout.setHorizontalGroup(
            PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelAcademicoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelAcademicoLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(PanelAcademicoLayout.createSequentialGroup()
                        .addGroup(PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel21)
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(cbodato, 0, 356, Short.MAX_VALUE)
                            .addComponent(txtDescripcion))
                        .addGroup(PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PanelAcademicoLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnTipoAcademico)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelAcademicoLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnagregarAcademicos)
                                .addGap(66, 66, 66))))))
        );
        PanelAcademicoLayout.setVerticalGroup(
            PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelAcademicoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(cbodato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTipoAcademico))
                .addGap(25, 25, 25)
                .addGroup(PanelAcademicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnagregarAcademicos)
                    .addComponent(jLabel21))
                .addGap(31, 31, 31)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jToolBar4.setBorder(null);
        jToolBar4.setFloatable(false);
        jToolBar4.setBorderPainted(false);

        btnnuevo.setText("Nuevo");
        btnnuevo.setFocusable(false);
        btnnuevo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnnuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnnuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnnuevoActionPerformed(evt);
            }
        });
        jToolBar4.add(btnnuevo);

        btnguardar.setText("Guardar");
        btnguardar.setFocusable(false);
        btnguardar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnguardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnguardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnguardarActionPerformed(evt);
            }
        });
        jToolBar4.add(btnguardar);

        btnactualizar.setText("Actualizar");
        btnactualizar.setFocusable(false);
        btnactualizar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnactualizar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnactualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnactualizarActionPerformed(evt);
            }
        });
        jToolBar4.add(btnactualizar);

        btnsalir.setText("Salir");
        btnsalir.setFocusable(false);
        btnsalir.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnsalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnsalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnsalirActionPerformed(evt);
            }
        });
        jToolBar4.add(btnsalir);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Alumno", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel22.setText("CEDULA");

        txtcedula.setEditable(false);

        btnbuscar.setBackground(new java.awt.Color(255, 255, 255));
        btnbuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/buscar.png"))); // NOI18N
        btnbuscar.setFocusable(false);
        btnbuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnbuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnbuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnbuscarActionPerformed(evt);
            }
        });

        txtalumno.setEditable(false);

        jLabel23.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel23.setText("ALUMNO");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel22)
                .addGap(30, 30, 30)
                .addComponent(txtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel23)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtalumno, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(btnbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(txtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtalumno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23))))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(PanelAcademico, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToolBar4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(PanelAcademico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tblAcademicoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblAcademicoMouseClicked
        if (evt.getClickCount() == 2) {
            llenarTablaAcademico(tblAcademico.getSelectedRow());
        }
    }//GEN-LAST:event_tblAcademicoMouseClicked

    private void btnagregarAcademicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnagregarAcademicosActionPerformed
        agregarAcademico();
    }//GEN-LAST:event_btnagregarAcademicosActionPerformed

    private void btnTipoAcademicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTipoAcademicoActionPerformed
        String combo;
        combo = global.Mensajes.mostrarDialogoconTexto("AGREGAR DATO ACADÉMICO", null);
        if (combo != null) {
            cbodato.addItem(combo.toUpperCase());
        }
    }//GEN-LAST:event_btnTipoAcademicoActionPerformed

    private void txtDescripcionKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDescripcionKeyReleased
        global.Validaciones.convertirMayuscula(txtDescripcion);
    }//GEN-LAST:event_txtDescripcionKeyReleased

    private void btnnuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnnuevoActionPerformed
        limpiarTodo();
    }//GEN-LAST:event_btnnuevoActionPerformed

    private void btnsalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsalirActionPerformed
        dispose();
        limpiarTodo();
    }//GEN-LAST:event_btnsalirActionPerformed

    private void btnactualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnactualizarActionPerformed
        int n = 0;
        frmConsultaAcademico.objAcademico.setCedulaAlumno(txtcedula.getText());
        frmConsultaAcademico.objAcademico.eliminarAcademico();
        for (int i = 0; i < tblAcademico.getRowCount(); i++) {
            frmConsultaAcademico.objAcademico.setDescripcionAcademico(tblAcademico.getValueAt(i, 1).toString());
            frmConsultaAcademico.objAcademico.setTipoAcademico(tblAcademico.getValueAt(i, 0).toString());
            if (frmConsultaAcademico.objAcademico.guardarAcademico() == true) {
                n++;
            }
        }

        if (n == tblAcademico.getRowCount()) {
            Dialogos.ActualizadoconExito();
            frmConsultaAcademico.generartabla();
            dispose();
            limpiarTodo();
        } else {
            Dialogos.Error("Error al actualizar los datos");
        }
    }//GEN-LAST:event_btnactualizarActionPerformed

    private void btnbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbuscarActionPerformed
        dlgConsultaMatricula alumno = new dlgConsultaMatricula(null, true);
        alumno.setVisible(true);
        btnbuscar.setVisible(false);
    }//GEN-LAST:event_btnbuscarActionPerformed

    private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
        int n = 0;
        frmConsultaAcademico.objAcademico.setCedulaAlumno(txtcedula.getText());
        for (int i = 0; i < tblAcademico.getRowCount(); i++) {
            frmConsultaAcademico.objAcademico.setDescripcionAcademico(tblAcademico.getValueAt(i, 1).toString());
            frmConsultaAcademico.objAcademico.setTipoAcademico(tblAcademico.getValueAt(i, 0).toString());
            if (frmConsultaAcademico.objAcademico.guardarAcademico() == true) {
                n++;
            }
        }

        if (n == tblAcademico.getRowCount()) {
            Dialogos.GuardadoconExito();
            frmConsultaAcademico.generartabla();
            limpiarTodo();
        } else {
            Dialogos.Error("Error al guardar los datos");
        }
    }//GEN-LAST:event_btnguardarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(dlgAcademico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(dlgAcademico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(dlgAcademico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(dlgAcademico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                dlgAcademico dialog = new dlgAcademico(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel PanelAcademico;
    private javax.swing.JButton btnTipoAcademico;
    private javax.swing.JButton btnactualizar;
    private javax.swing.JButton btnagregarAcademicos;
    public javax.swing.JButton btnbuscar;
    private javax.swing.JButton btnguardar;
    private javax.swing.JButton btnnuevo;
    private javax.swing.JButton btnsalir;
    private javax.swing.JComboBox cbodato;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar jToolBar4;
    public static javax.swing.JTable tblAcademico;
    private javax.swing.JTextField txtDescripcion;
    public static javax.swing.JTextField txtalumno;
    public static javax.swing.JTextField txtcedula;
    // End of variables declaration//GEN-END:variables
}
